<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Functions</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="GTK+ 2.0 Tutorial"
HREF="book1.html"><LINK
REL="UP"
TITLE="Drag-and-drop (DND)"
HREF="c1901.html"><LINK
REL="PREVIOUS"
TITLE="Properties"
HREF="x1923.html"><LINK
REL="NEXT"
TITLE="GLib"
HREF="c2025.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>GTK+ 2.0 Tutorial</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x1923.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Drag-and-drop (DND)</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="c2025.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="SEC-DRAGANDDROPFUNCTIONS"
>Functions</A
></H1
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="SEC-DNDSOURCEWIDGETS"
>Setting up the source widget</A
></H2
><P
>The function <TT
CLASS="LITERAL"
>gtk_drag_source_set()</TT
> specifies a
set of target types for a drag operation on a widget.</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void gtk_drag_source_set( GtkWidget            *widget,
                          GdkModifierType       start_button_mask,
                          const GtkTargetEntry *targets,
                          gint                  n_targets,
                          GdkDragAction         actions );</PRE
></TD
></TR
></TABLE
><P
>The parameters signify the following:</P
><P
></P
><UL
><LI
><P
><TT
CLASS="LITERAL"
>widget</TT
> specifies the drag source
widget</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>start_button_mask</TT
> specifies a
bitmask of buttons that can start the drag (e.g. GDK_BUTTON1_MASK)</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>targets</TT
> specifies a table of
target data types the drag will support</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>n_targets</TT
> specifies the number of
targets above</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>actions</TT
> specifies a bitmask of
possible actions for a drag from this window</P
></LI
></UL
><P
>The <TT
CLASS="LITERAL"
>targets</TT
> parameter is an array of the
following structure:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>struct GtkTargetEntry {
   gchar *target;
   guint  flags;
   guint  info;
 };</PRE
></TD
></TR
></TABLE
><P
>The fields specify a string representing the drag type, optional
flags and application assigned integer identifier.</P
><P
>If a widget is no longer required to act as a source for
drag-and-drop operations, the function
<TT
CLASS="LITERAL"
>gtk_drag_source_unset()</TT
> can be used to remove a set
of drag-and-drop target types.</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void gtk_drag_source_unset( GtkWidget *widget );</PRE
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="SEC-SIGNALSONSOURCEWIDGETS"
>Signals on the source widget:</A
></H2
><P
>The source widget is sent the following signals during a
drag-and-drop operation.</P
><DIV
CLASS="TABLE"
><A
NAME="AEN1975"
></A
><P
><B
>Table 1. Source widget signals</B
></P
><TABLE
BORDER="1"
WIDTH="100%"
BGCOLOR="#E0E0E0"
CELLSPACING="0"
CELLPADDING="4"
CLASS="CALSTABLE"
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>drag_begin</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="LITERAL"
>void (*drag_begin)(GtkWidget *widget,
GdkDragContext *dc, gpointer data)</TT
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>drag_motion</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="LITERAL"
>gboolean (*drag_motion)(GtkWidget *widget,
GdkDragContext *dc, gint x, gint y, guint t, gpointer data)</TT
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>drag_data_get</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="LITERAL"
>void (*drag_data_get)(GtkWidget *widget,
GdkDragContext *dc, GtkSelectionData *selection_data, guint info, guint t, gpointer data)</TT
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>drag_data_delete</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="LITERAL"
>void (*drag_data_delete)(GtkWidget *widget,
GdkDragContext *dc, gpointer data)</TT
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>drag_drop</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="LITERAL"
>gboolean (*drag_drop)(GtkWidget *widget,
GdkDragContext *dc, gint x, gint y, guint t, gpointer data)</TT
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>drag_end</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="LITERAL"
>void (*drag_end)(GtkWidget *widget,
GdkDragContext *dc, gpointer data)</TT
></TD
></TR
></TBODY
></TABLE
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="SEC-DNDDESTWIDGETS"
>Setting up a destination widget:</A
></H2
><P
> <TT
CLASS="LITERAL"
> gtk_drag_dest_set()</TT
> specifies
that this widget can receive drops and specifies what types of drops it
can receive.</P
><P
> <TT
CLASS="LITERAL"
> gtk_drag_dest_unset()</TT
> specifies
that the widget can no longer receive drops.</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void gtk_drag_dest_set( GtkWidget            *widget,
                        GtkDestDefaults       flags,
                        const GtkTargetEntry *targets,
                        gint                  n_targets,
                        GdkDragAction         actions );

void gtk_drag_dest_unset( GtkWidget *widget );</PRE
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="SEC-SIGNALSONDESTWIDGETS"
>Signals on the destination widget:</A
></H2
><P
>The destination widget is sent the following signals during a
drag-and-drop operation.</P
><DIV
CLASS="TABLE"
><A
NAME="AEN2015"
></A
><P
><B
>Table 2. Destination widget signals</B
></P
><TABLE
BORDER="1"
WIDTH="100%"
BGCOLOR="#E0E0E0"
CELLSPACING="0"
CELLPADDING="4"
CLASS="CALSTABLE"
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>drag_data_received</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="LITERAL"
>void (*drag_data_received)(GtkWidget *widget,
GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data, guint info, guint t,
gpointer data)</TT
></TD
></TR
></TBODY
></TABLE
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x1923.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="c2025.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Properties</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c1901.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>GLib</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>